Skip to content

Conversation

@Kn99HN
Copy link
Contributor

@Kn99HN Kn99HN commented Apr 23, 2021

Description

  • Generate installation instruction for user to copy paste when dnspython is not installed.

Note for reviewers

  • I wasn't sure about getting path for Python so I think this is the most straightforward but having to import os only for the path seems a bit excessive. But let me know if you would like me to change it :)

scheme_free = uri[SCHEME_LEN:]
elif uri.startswith(SRV_SCHEME):
if not _HAVE_DNSPYTHON:
python_path = os.getenv('_', "python")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of os.getenv let's use sys.executable like this:

python_path = sys.executable or 'python'

https://docs.python.org/3/library/sys.html#sys.executable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

'To fix this error install pymongo '
'with the srv extra:\n '
'%s -m pip install "pymongo[srv]"'
% (python_path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make this more readable by formatting like this:

            raise ConfigurationError(
                'The "dnspython" module must be installed to use '
                'mongodb+srv:// URIs. To fix this error...'

@ShaneHarvey ShaneHarvey merged commit 5388fde into mongodb:master Apr 26, 2021
ShaneHarvey pushed a commit that referenced this pull request Apr 26, 2021
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kn99HN!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants